#ifndef	LANGUAGE_PARSERS_H
#define LANGUAGE_PARSERS_H

#include "LanguageTypes.h"
#include "LanguageGrammar.h"
#include "SymbolsFlow.h"
#include <vector>
using namespace std;

class Compiler;
//common language parser class
class LanguageParsers
{
public:
	LanguageParsers(Compiler* compiler);

public:
    virtual bool Initialize() { return true; }
    //保存语法分析器状态到文件
    virtual bool Save(ostream& o) {}
    virtual bool Save();
    //从文件加载语法分析器状态
    virtual bool Load(istream& i) {}
    bool Load();
    virtual string GetParserType() = 0;
    string GetCacheFileName();
public:

    virtual void Show() {}
	//input symbols --> source parse grammar tree
    virtual bool Parse(SymbolsFlow& input_symbols, LanguageTree*& source_tree, Symbols start_symbol) = 0;
protected:
	const LanguageGrammar& languages;
    Compiler* compiler;
};//end of LanguageParsers

#endif //LANGUAGE_PARSERS_H

